home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-01-10 | 2.0 KB | 46 lines | [TEXT/ttxt] |
- --WARNING!!! This script must be saved as an executable application before using
- -- it with MacHTTP. Use Save As an Application with the Keep Open and
- -- Never Show Startup Screen boxes checked!!!!
- --
- -- This script demonstrates accessing searchable files from MacHTTP.
- -- (What it really shows is how to pass AppleEvent arguments to AppleScripts.)
- -- http_search_args is defined from an AppleEvent passed from the server
- -- to the script and contains the client-supplied search arguments. If the arguments
- -- are empty, the script returns HTML asking the WWW client to prompt for them.
- -- If arguments were passed, then the script behaves accordingly.
- -- Note: the <ISINDEX> HTML tag is what tells the client the document is searchable
- -- and arguments should be collected and passed.
-
- set byebye to false --This flag is used to cause the script to (eventually) quit
-
- -- The following is a handler for a specific AppleEvent that is sent
- -- by MacHTTP to applications. The event suite is 'WWWΩ' and the event itself
- -- is the "search" event, 'srch'. The direct parameter contains the
- -- search arguments passed from the WWW client to MacHTTP.
- -- Note: The "«" character is generated by typing option-\ and "»" is obtained by typing option-|.
- --
- -- This very simple "search" looks for the word "hello" and responds accordingly
-
- on «event WWWΩsrch» http_search_args
- global byebye
- if http_search_args = "" then --no args passed, tell the client to prompt for them
- set byebye to true
- return "<ISINDEX><h2>Please enter the keyword to search for.</h2>"
- else if http_search_args = "hello" then --the arg matches
- set byebye to true
- return "<h2>Hello, how are you?</h2>"
- else --the arg doesn't match
- set byebye to true
- return "<h2>Sorry, I don't understand '" & ¬
- http_search_args & "'. Try 'hello' instead.</h2>"
- end if
- quit
- end «event WWWΩsrch»
-
- --The idle handler will cause the script to (eventually) quit. I'd
- --love to hear if there's a better way to do this.
-
- on idle
- global byebye
- if byebye then quit
- end idle